﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="User.aspx.cs" Inherits="WebPresentation.User" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .nodisplay 
        {
            display:block
        }
        .style3
        {
            width: 467px;
        }
        </style>
    <script type="text/javascript" src="Scripts/jquery.ui.datepicker.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.8.20.custom.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $('.hiddenField, #MainContent_dtgdoc th:nth-child(2)').hide();
            $("#MainContent_LinkButtonsearch").click(function () {
                $("#search").toggle();
                return false;
            });
            $("#MainContent_LinkButtonadd").click(function () {
                $("#add").toggle();
                $("#edit").hide();
                $("#delete").hide();
                return false;
            });
            $("#MainContent_LinkButtonedit").click(function () {
                $("#edit").toggle();
                $("#add").hide();
                $("#delete").hide();
                return false;
            });
        });
	      
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div align="center">
    
    <asp:Label ID="Label10" runat="server" Width="100%" ForeColor="Red" 
        Font-Bold="True"></asp:Label>
    
</div>
<br />
<div>
    <table style="width: 100%;">
        <tr>
            <td align="center" width="25%">
                &nbsp;
                <asp:LinkButton ID="LinkButtonadd" runat="server">Go to add page</asp:LinkButton>
            </td>
            <td align="center" width="25%">
                <asp:LinkButton ID="LinkButtonedit" runat="server" 
                    onclick="LinkButtonedit_Click">Go to edit page</asp:LinkButton>
                &nbsp;
            </td>
            <td align="center" width="25%">
                
                <asp:LinkButton ID="LinkButtondel" runat="server" onclick="LinkButtondel_Click">Go to delete page</asp:LinkButton>
                
            </td>
            <td align="center" width="25%">
                <asp:LinkButton ID="LinkButtonsearch" runat="server">Go to search</asp:LinkButton>
                &nbsp;
            </td>
        </tr>
    </table>
</div>
<br />
<div id="add" style="display:none">
    <fieldset>
    <legend>User Information:</legend>
       <table style="width:100%;" cellspacing="10px">
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label1" runat="server" Text="Role:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:DropDownList ID="ddlRole" runat="server" Height="20px" Width="150px" 
                        DataSourceID="RoleObjectSource" DataTextField="rName" DataValueField="rID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="RoleObjectSource" runat="server" 
                        DeleteMethod="DeleteRoll" InsertMethod="AddNewRoll" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllRoll" 
                        TypeName="BusinessLogic.RoleBO" UpdateMethod="UpdateRoll">
                        <DeleteParameters>
                            <asp:Parameter Name="rID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="rName" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="rName" Type="String" />
                            <asp:Parameter Name="rID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label2" runat="server" Text="First Name:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtFirstName" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                            ControlToValidate="txtFirstName" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label3" runat="server" Text="Last Name:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtLastName" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                            ControlToValidate="txtLastName" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                    </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label4" runat="server" Text="Address:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtAddress" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                            ControlToValidate="txtAddress" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                    </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label5" runat="server" Text="Phone Number:" Width="120px" 
                        Height="16px" style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtPhone" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                            ControlToValidate="txtPhone" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label6" runat="server" Text="Department:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:DropDownList ID="ddldepartment" runat="server" Height="20px" Width="150px" 
                        DataSourceID="DepartmentObjectSource" DataTextField="depName" 
                        DataValueField="depID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="DepartmentObjectSource" runat="server" 
                        DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDepartments" 
                        TypeName="BusinessLogic.DepartmentBO" UpdateMethod="UpdateDepartment">
                        <DeleteParameters>
                            <asp:Parameter Name="depID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="depName" Type="String" />
                            <asp:Parameter Name="depCode" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="depName" Type="String" />
                            <asp:Parameter Name="depCode" Type="String" />
                            <asp:Parameter Name="depID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label7" runat="server" Text="Position:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:DropDownList ID="ddlposition" runat="server" Height="20px" Width="150px" 
                        DataSourceID="PositionObjectSource" DataTextField="pName" DataValueField="pID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="PositionObjectSource" runat="server" 
                        DeleteMethod="DeletePosition" InsertMethod="AddNewPosition" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllPositions" 
                        TypeName="BusinessLogic.PositionBO" UpdateMethod="UpdatePosition">
                        <DeleteParameters>
                            <asp:Parameter Name="pID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="pName" Type="String" />
                            <asp:Parameter Name="pCode" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="pName" Type="String" />
                            <asp:Parameter Name="pCode" Type="String" />
                            <asp:Parameter Name="pID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label8" runat="server" Text="Email:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtmail" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
                            ControlToValidate="txtmail" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label9" runat="server" Text="Password:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtpass" runat="server" TextMode="Password" Height="20px" 
                        Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
                            ControlToValidate="txtpass" ErrorMessage="Require Field" Font-Bold="True" 
                            ForeColor="Red" ValidationGroup="add"></asp:RequiredFieldValidator>
                        <br />
                </td>
            </tr>
        </table>    
    <br />
    <div align="center">
               
        <asp:ImageButton ID="ImageButtonadd" runat="server" 
            ImageUrl="~/Images/addbutton.png" onclick="ImageButtonadd_Click" 
            ValidationGroup="add" />
               
    </div>
</fieldset>
</div>
<div id="edit" style="display:none">
    <fieldset>
    <legend>User Information:</legend>
       <table style="width:100%;" cellspacing="10px">
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label11" runat="server" Text="Role:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:DropDownList ID="ddlRoleEdit" runat="server" Height="20px" Width="150px" 
                        DataSourceID="RoleObjectSource" DataTextField="rName" DataValueField="rID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        DeleteMethod="DeleteRoll" InsertMethod="AddNewRoll" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllRoll" 
                        TypeName="BusinessLogic.RoleBO" UpdateMethod="UpdateRoll">
                        <DeleteParameters>
                            <asp:Parameter Name="rID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="rName" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="rName" Type="String" />
                            <asp:Parameter Name="rID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label12" runat="server" Text="First Name:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtFirstNameEdit" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label13" runat="server" Text="Last Name:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtLastNameEdit" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                    </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label14" runat="server" Text="Address:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" width="302px">
                    <asp:TextBox ID="txtAddressEdit" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                    </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label15" runat="server" Text="Phone Number:" Width="120px" 
                        Height="16px" style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtPhoneEdit" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label16" runat="server" Text="Department:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:DropDownList ID="ddlrepEdit" runat="server" Height="20px" Width="150px" 
                        DataSourceID="DepartmentObjectSource" DataTextField="depName" 
                        DataValueField="depID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                        DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDepartments" 
                        TypeName="BusinessLogic.DepartmentBO" UpdateMethod="UpdateDepartment">
                        <DeleteParameters>
                            <asp:Parameter Name="depID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="depName" Type="String" />
                            <asp:Parameter Name="depCode" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="depName" Type="String" />
                            <asp:Parameter Name="depCode" Type="String" />
                            <asp:Parameter Name="depID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label17" runat="server" Text="Position:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:DropDownList ID="ddlposEdit" runat="server" Height="20px" Width="150px" 
                        DataSourceID="PositionObjectSource" DataTextField="pName" 
                        DataValueField="pID">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" 
                        DeleteMethod="DeletePosition" InsertMethod="AddNewPosition" 
                        OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllPositions" 
                        TypeName="BusinessLogic.PositionBO" UpdateMethod="UpdatePosition">
                        <DeleteParameters>
                            <asp:Parameter Name="pID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="pName" Type="String" />
                            <asp:Parameter Name="pCode" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="pName" Type="String" />
                            <asp:Parameter Name="pCode" Type="String" />
                            <asp:Parameter Name="pID" Type="Int32" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="center" width="302px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label18" runat="server" Text="Email:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtMailEdit" runat="server" Height="20px" Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                </td>
            </tr>
            <tr>
                <td align="right" class="style3">
                    <asp:Label ID="Label19" runat="server" Text="Password:" Width="120px" 
                        style="text-align:left" Font-Bold="True"></asp:Label>
                </td>
                <td align="center" style="margin-left: 40px" width="302px">
                    <asp:TextBox ID="txtPassEdit" runat="server" TextMode="Password" Height="20px" 
                        Width="200px"></asp:TextBox>
                </td>
                <td align="center" width="302px">
                        <br />
                </td>
            </tr>
        </table>    
    <br />
    <div align="center">
               
        <asp:ImageButton ID="ImageButtonedit" runat="server" 
            ImageUrl="~/Images/editbutton.png" onclick="ImageButtonedit_Click" />
               
    </div>
</fieldset>
</div>
<br />
<fieldset>
    <legend>Details:</legend>
    <div>
        
        <asp:GridView ID="dtguser" runat="server" Width="100%" CellPadding="4" 
            ForeColor="#333333" GridLines="None" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="uID" 
            DataSourceID="UserObjectSource" 
            onselectedindexchanged="dtguser_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="uID" HeaderText="uID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="uID" >
                <ItemStyle CssClass="hiddenField" />
                </asp:BoundField>
                <asp:BoundField DataField="FullName" HeaderText="FullName" ReadOnly="True" 
                    SortExpression="FullName" />
                <asp:BoundField DataField="uAddress" HeaderText="uAddress" 
                    SortExpression="uAddress" />
                <asp:BoundField DataField="uPhone" HeaderText="uPhone" 
                    SortExpression="uPhone" />
                <asp:BoundField DataField="uEmail" HeaderText="uEmail" 
                    SortExpression="uEmail" />
                <asp:BoundField DataField="uPassword" HeaderText="uPassword" 
                    SortExpression="uPassword" />
                <asp:BoundField DataField="rName" HeaderText="rName" SortExpression="rName" />
                <asp:BoundField DataField="Department" HeaderText="Department" 
                    SortExpression="Department" />
                <asp:BoundField DataField="Position" HeaderText="Position" 
                    SortExpression="Position" />
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        
        <asp:ObjectDataSource ID="UserObjectSource" runat="server" 
            DeleteMethod="Delete" InsertMethod="AddNewUser" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllUsers" 
            TypeName="BusinessLogic.UserBO" UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="uID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="rID" Type="Int32" />
                <asp:Parameter Name="uFName" Type="String" />
                <asp:Parameter Name="uLName" Type="String" />
                <asp:Parameter Name="uAddress" Type="String" />
                <asp:Parameter Name="uPhone" Type="String" />
                <asp:Parameter Name="uDepartment" Type="Int32" />
                <asp:Parameter Name="uPassword" Type="String" />
                <asp:Parameter Name="uEmail" Type="String" />
                <asp:Parameter Name="uPosition" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="rID" Type="Int32" />
                <asp:Parameter Name="uFName" Type="String" />
                <asp:Parameter Name="uLName" Type="String" />
                <asp:Parameter Name="uPassword" Type="String" />
                <asp:Parameter Name="uEmail" Type="String" />
                <asp:Parameter Name="uPosition" Type="Int32" />
                <asp:Parameter Name="uDepartment" Type="Int32" />
                <asp:Parameter Name="uPhone" Type="String" />
                <asp:Parameter Name="uAddress" Type="String" />
                <asp:Parameter Name="uID" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
        
    </div>
</fieldset>
</asp:Content>
